﻿using PrjAssessModels;
using PrjAssessModels.BaseModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PrjAssess.Models.Service.AssessProject
{
    public class ReAssessLimit
    {
        //上下限制,假如超出,则进行重新测算
        private static double _maxMaterialBury = 1.1;
        private static double _minMaterialBury = 0.9;

        private static double _maxWork = 1.2;
        private static double _minWork = 0.8;

        public static bool NeedReAssess(Project prj,out string msg)
        {
            msg = "";
            Project prj_exist = ProjectDataHelper.GetByPrjId(prj.PrjId);
            bool is_mb_exceed = true;
            bool is_w_exceed = true;
            if ((prj.MaterialBurySum < (prj_exist.MaterialBurySum * _maxMaterialBury)) && (prj.MaterialBurySum > (prj_exist.MaterialBurySum * _minMaterialBury)))
            {
                is_mb_exceed = false;
            }
            if ((prj.WorkSum < (prj_exist.WorkSum * _maxWork)) && (prj.WorkSum > (prj_exist.WorkSum * _minWork)))
            {
                is_w_exceed = false;
            }
            if (is_w_exceed == false && is_mb_exceed == false)
            {
                msg = "";
                return false;
            }
            else
            {
                msg = "材料埋设或工作量有超限,需要重算!";
                return true;
            }
        }
    }
}